package com.zyl.common

import org.apache.spark.internal.Logging
import org.apache.spark.sql.SparkSession

abstract class SparkTools extends Logging with Constant {

  var day_id: String = _
  var month_id: String = _

  def main(args: Array[String]): Unit = {

    /**
      * 获取时间参数
      *
      */

    if (args.length == 0) {
      logWarning("请传入时间参数")
    } else {
      day_id = args(0)
      logInfo(s"时间参数$day_id")

      month_id = day_id.substring(0, 6)

    }


    logInfo("创建Spark环境")
    val spark: SparkSession = SparkSession
      .builder()

      .appName(this.getClass.getSimpleName.replace("$", ""))

      .enableHiveSupport() //获取hive元数据
      .getOrCreate()


    run(spark)

  }

  def run(spark: SparkSession)

}
